package com.kingsoft.dc.khaos.module.spark.model.exchangefile;

/**
 * Created by jing on 19/3/7.
 */
public class ExchangeFileUtils {

    /**
     * 生成基础文件名$objectPrefix_$bizDate_$batchNo
     *
     * @param objectPrefix,bizDate,batchNo
     * @return
     */
    public static String genBaseFileName(String objectPrefix, String bizDate, String batchNo) {
        return String.format("%s_%s_%s", objectPrefix, bizDate, batchNo);
    }


    /**
     * 根据基础文件名生成编号后的文件名
     *
     * @param fileName
     * @param index
     * @return
     */
    public static String genFileNameByIndex(String fileName, int index) {
        if (index <= 0) {
            return String.format("%s", fileName);
        }
        return String.format("%s_%s", fileName, index);
    }

    /**
     * 生成数据文件名,$baseFile.dat
     *
     * @param fileName
     * @return
     */
    public static String genDatFileName(String fileName) {
//        return String.format("%s.dat", fileName);
        return String.format("%s.csv", fileName);
    }

    /**
     * 生成数据文件名,$baseFile.dat
     *
     * @param fileName
     * @return
     */
    public static String genOrcFileName(String fileName) {
        return String.format("%s.orc", fileName);
    }

    /**
     * 生成数据文件名,$baseFile.dat
     *
     * @param fileName
     * @return
     */
    public static String genJsonFileName(String fileName) {
//        return String.format("%s.dat", fileName);
        return String.format("%s.json", fileName);
    }

    /**
     * 生成控制文件名,$baseFile_ctrl.xml
     *
     * @param fileName
     * @return
     */
    public static String genControlFileName(String fileName) {
        return String.format("%s.xml", fileName);
//        return String.format("%s_ctrl.xml", fileName);
    }

    /**
     * 生成DDL文件名,$$baseFile_ddl.xml
     *
     * @param fileName
     * @return
     */
    public static String genDDLFileName(String fileName) {
        return String.format("%s.ddl", fileName);
//        return String.format("%s_ddl.xml", fileName);
    }
}
